<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加大蜡烛</title>
    <style>
        .two-part-label{
            width: 200px !important;
        }
    </style>
</head>
<body>
<form class="layui-form" lay-filter="layui-form">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label" title="日期">日期</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input"
                           name="date" id="date" data-type="date"
                           autocomplete="off" placeholder="请选择日期" lay-verify="" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" title="蜡烛-地点">
                    蜡烛-地点</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="candle_data_ids"
                         data-sourceType="route"
                         data-source="/admin.sky.candleData/getTreeData"
                         data-sourceTree="true"
                         data-paging="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择类型"
                    ></div>
                </div>
            </div>

        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="laytp-btn laytp-btn-primary laytp-btn-sm" lay-submit="" lay-filter="add">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="laytp-btn laytp-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script>
    if(localStorage.getItem("staticDomain")){
        document.write("<link rel='stylesheet' href='" + localStorage.getItem("staticDomain") + "/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
    }else{
        document.write("<link rel='stylesheet' href='/static/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='/static/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='/static/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
    }
</script>
<script>
    layui.use(['laytp','xmSelect','laydate'], function () {
        let laydate = layui.laydate;
        //日期
        var myDate =  new Date();  //获取当前时间
        var d = myDate.getDate();
        if(d<10){
            d = "0"+d;
        }
        laydate.render({
            elem: '#date'
            ,min:myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+d
        });
        layui.form.on('submit(add)', function(data){
            var btnAnim = layui.button.load({elem:$(this)});
            facade.ajax({
                route:'/admin.sky.candle/add',
                data : data.field
            }).done(function(res){
                if(res.code === 0){
                    parent.layui.layer.close(parent.layui.layer.getFrameIndex(window.name));//关闭当前页
                    parent.funController.tableRender();
                    parent.parent.renderMenu();//重新渲染菜单
                }
                btnAnim.stop();
            }).fail(function(){
                btnAnim.stop();
            });
            return false;
        });
    });
</script>
</body>
</html>